package com.systop.asset.controller;

import com.systop.asset.entity.InventoryCheckDetail;
import com.systop.asset.entity.RestResponse;
import com.systop.asset.entity.vo.CheckAssetVo;
import com.systop.asset.entity.vo.CheckMaterialVo;
import com.systop.asset.service.IInventoryCheckDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 盘点单明细Controller
 * 
 * @author lsp
 * @date 2025-07-07
 */
@RestController
@RequestMapping("/check/detail")
public class InventoryCheckDetailController
{
    @Autowired
    private IInventoryCheckDetailService inventoryCheckDetailService;

    /**
     * 查询盘点单明细列表
     */
    @GetMapping("/list")
    public RestResponse list(InventoryCheckDetail inventoryCheckDetail)
    {
        
        List<InventoryCheckDetail> list = inventoryCheckDetailService.selectInventoryCheckDetailList(inventoryCheckDetail);
        return RestResponse.success(list);
    }
    
    /**
     * 获取盘点单明细详细信息
     */
    @GetMapping(value = "/{inventoryCheckDetailId}")
    public RestResponse getInfo(@PathVariable("inventoryCheckDetailId") Long inventoryCheckDetailId)
    {
        return RestResponse.success(inventoryCheckDetailService.selectInventoryCheckDetailByInventoryCheckDetailId(inventoryCheckDetailId));
    }

    @GetMapping("/checkAssetList")
    public RestResponse checkAssetList(InventoryCheckDetail inventoryCheckDetail)
    {

        List<CheckAssetVo> list = inventoryCheckDetailService.selectCheckAssetList(inventoryCheckDetail);
        return RestResponse.success(list);
    }

    @GetMapping("/checkDetailBySelf")
    public RestResponse checkAssetBySelf()
    {

        List<CheckAssetVo> list = inventoryCheckDetailService.selectCheckAssetBySelf();
        return RestResponse.success(list);
    }

    @GetMapping("/checkMaterial/{checkId}")
    public RestResponse CheckMaterial(@PathVariable("checkId") Long checkId)
    {

        List<CheckMaterialVo> list = inventoryCheckDetailService.selectCheckMaterial(checkId);
        return RestResponse.success(list);
    }

    /**
     * 新增盘点单明细
     */
    @PostMapping
    public RestResponse add(@RequestBody InventoryCheckDetail inventoryCheckDetail)
    {
        return RestResponse.success(inventoryCheckDetailService.insertInventoryCheckDetail(inventoryCheckDetail));
    }

    /**
     * 修改盘点单明细
     */
    @PutMapping
    public RestResponse edit(@RequestBody InventoryCheckDetail inventoryCheckDetail)
    {
        return RestResponse.success(inventoryCheckDetailService.updateInventoryCheckDetail(inventoryCheckDetail));
    }
    /**
     * 保存盘点单
     */
    @PutMapping("/saveCheck")
    public RestResponse saveCheck(@RequestBody InventoryCheckDetail[] inventoryCheckDetail)
    {
        return RestResponse.success(inventoryCheckDetailService.updateInventoryCheckDetail(inventoryCheckDetail));
    }
    /**
     * 删除盘点单明细
     */
	@DeleteMapping("/{inventoryCheckDetailIds}")
    public RestResponse remove(@PathVariable Long[] inventoryCheckDetailIds)
    {
        return RestResponse.success(inventoryCheckDetailService.deleteInventoryCheckDetailByInventoryCheckDetailIds(inventoryCheckDetailIds));
    }
}
